gusucode.com > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM源码程序 > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM\stprtool\generalp\pdiscrim.m
function pdiscrim( D, X, Y, background, linestyle ) % PDISCRIM plot discriminat functions regions in 2D. % pdiscrim( D, X, Y ) % % Input: % D [m x n] value of discriminat function in the binary case or % D [c x (m*n)] values of discriminant functions for all the % classes in the multi-class case. % X [1 x m] values of x-axis. % Y [1 x n] values of y-axis, e.g. X=[1:10], Y=[1:10] (mash 10x10). % % Modifications: % 23-sep-2002, VF % 21-may-2001, V.Franc, created if nargin < 4, background = 1; end if nargin < 5, linestyle = 'k'; end dx=X(2)-X(1); dy=Y(2)-Y(1); m = length( X ); n = length( Y ); Z = -inf*ones( m+2, n+2 ); nclass = size(D,1); if min( size( D )) == 1, A=D; l=(-min(A)+max(A))/2; A = reshape( A', m, n ); if background, phandle = pcolor(X,Y,A'); shading interp; end contour(X,Y,A',[0 0],linestyle); if background, set(phandle, 'LineStyle','none' ); set(gca,'Clim',[-l l]); load cmp1; colormap( cmp ); end elseif nclass == 2, A=D(1,:) - D(2,:); l=(-min(A)+max(A))/2; A = reshape( A', m, n ); if background, phandle = pcolor(X,Y,A'); shading interp; end contour(X,Y,A',[0 0],linestyle); if background, set(phandle, 'LineStyle','none' ); set(gca,'Clim',[-l l]); load cmp1; colormap( cmp ); end else for i = 1: nclass, A = D(i,:) - max(D(find([1:nclass] ~= i),:)); A = reshape( A', m, n ); Z(2:end-1,2:end-1) = A; [cc,h] = contour([X(1)-dx,X,X(end)+dx],[Y(1)-dy,Y,Y(end)+dy],Z',[0 0],... linestyle); if background, while ~isempty(cc) len = cc(2,1); fill(cc(1,2:len+1),cc(2,2:len+1),color(i)); cc(:,1:len+1) = []; end end end end return;